
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <sys/eventfd.h>
#include <unistd.h>

int main()
{
    int evfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
    if(evfd < 0)
    {
        perror("eventfd create failed");
        return -1;
    }

    uint64_t val = 1;
    write(evfd, &val, sizeof(val));
    write(evfd, &val, sizeof(val));


    uint64_t res = 0;
    read(evfd, &res, sizeof(res));

    std::cout << res << std::endl;

    uint64_t res2 = 0;
    read(evfd, &res2, sizeof(res));
    std::cout << res2 << std::endl;

    close(evfd);

    return 0;
}